<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        let a='b';
        let b='b';
        console.log('b'==='b'); // true
        console.log(Symbol('b')===Symbol('b')) //false
        let a1=Symbol('a');
        let a2=a1;
        console.log(a2===a1) //true
        let s1=Symbol.for('kevin');
        let s2=Symbol.for('kevin');
        console.log(Symbol.keyFor(s1),s1===s2)
        // 如果怕重名，用Symbol就最好
        // Symbol是基本数据类型，但是在栈内存里面存放的是引用地址
        let s_a=Symbol('a')
        let obj={
            [Symbol('a')]:'a1',
            [Symbol('a')]:'a2',
            [s_a]:'hello'
        }
        // symbol不能枚举
        for (const key in obj) {
            if (Object.hasOwnProperty.call(obj, key)) {
                const element = obj[key];
                console.log(Symbol.keyFor(key))
                
            }
            console.log(Symbol.keyFor(key))
        }
        // 获取对象的symbols
        let symbols=Object.getOwnPropertySymbols(obj);
        console.log(Object.getOwnPropertySymbols(obj))
        console.dir(Symbol)
        console.log(obj.a)
        console.log(obj[Symbol('a')])//undefined
        console.log(Symbol.keyFor(Symbol('a')))//undefined
        console.log(obj[symbols[0]])
        console.log(obj[symbols[1]])
        console.log(obj[symbols[2]])
        
        console.log(obj,obj[s_a]) // hello

        // 使用场景：当你想要这个值是独一无二的时候
    </script>
</body>
</html>